
#ifndef __BSP_MX_H
#define __BSP_MX_H
#include "stm32f1xx_hal.h"
#include "cmsis_os.h"
#include "fatfs.h"
#include "fileos.h"
#include "ff.h"




#define USART1_BUFF_LEN 	128
#define USART2_BUFF_LEN 	128
#define USART3_BUFF_LEN 	512


extern uint16_t  Usart1_RxLen;
extern uint8_t 	Usart1_Rx_Sta;
extern uint8_t 	USART1_RX_BUF[USART1_BUFF_LEN];

extern uint16_t  Usart2_RxLen;
extern uint8_t 	Usart2_Rx_Sta;
extern uint8_t 	USART2_RX_BUF[USART2_BUFF_LEN];

extern uint16_t   Usart3_RxLen;
extern uint8_t 	  Usart3_Rx_Sta;
extern uint8_t 	  USART3_RX_BUF[USART3_BUFF_LEN];
extern uint32_t 	ADC_RX_BUF[8];



/* USER CODE END Includes */

/* Private variables ---------------------------------------------------------*/
extern ADC_HandleTypeDef hadc1;
extern IWDG_HandleTypeDef hiwdg;

extern SD_HandleTypeDef hsd;
extern HAL_SD_CardInfoTypedef SDCardInfo;
extern DMA_HandleTypeDef hdma_sdio;

extern SPI_HandleTypeDef hspi1;
extern SPI_HandleTypeDef hspi2;

extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
extern UART_HandleTypeDef huart3;
extern DMA_HandleTypeDef hdma_usart1_rx;
extern DMA_HandleTypeDef hdma_usart2_rx;
extern DMA_HandleTypeDef hdma_usart3_rx;

extern SRAM_HandleTypeDef hsram1;
extern SRAM_HandleTypeDef hsram2;
extern NAND_HandleTypeDef hnand1;
extern RTC_HandleTypeDef hrtc;


 void MX_GPIO_Init(void);
 void MX_DMA_Init(void);
 void MX_ADC1_Init(void);
 void MX_FSMC_Init(void);
 void MX_IWDG_Init(void);
 void MX_SDIO_SD_Init(void);
 void MX_SPI1_Init(void);
 void MX_SPI2_Init(void);
 void MX_USART1_UART_Init(void);
 void MX_USART2_UART_Init(void);
 void MX_USART3_UART_Init(void);
 void MX_RTC_Init(void);

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
void Error_Handler(void);

u16 Get_Adc(u32 ch);
u16 Get_AdcAvg(u32 ch,u16 times);
#endif

